<template>
  <div>
      <el-tree
          :style="'height:'+height+'px'"
          ref="singleTree"
          highlight-current
          :node-key="key"
          :check-on-click-node="true"
          :check-strictly="true"
          show-checkbox
          :data="dataList"
          :expand-on-click-node="false"
          :props="treeProps"
          @check-change="selectBuild"
          default-expand-all
        ></el-tree>
  </div>
</template>

<script>
export default {
  name:"singleTree",
  props:{
    height:{
      default:300,
      type:Number,
    },
    dataList:{
      default:[],
      type:Array,
    },
    treeProps:{
      default:{},
      type:Object,
    },
    key:{
      default:"",
      type:String
    }
  },
  data(){
    return {
      i: 0,
    }
  },
  methods:{
    selectBuild(data, checked, indeterminate){
      this.i++;
      if(this.i%2==0){
        if(checked){
           this.$refs.singleTree.setCheckedNodes([data.id]);
        }else{
          this.$refs.singleTree.setCheckedNodes([]);
        }
      }
    }
  }
}
</script>

<style>

</style>